Skip to content

feat(core): add URL elicitation support (SEP-1036)#939

Open
sainathreddyb wants to merge 1 commit into
modelcontextprotocol:mainfrom
sainathreddyb:feature/sep-1036-url-elicitation
Open

feat(core): add URL elicitation support (SEP-1036)#939
sainathreddyb wants to merge 1 commit into
modelcontextprotocol:mainfrom
sainathreddyb:feature/sep-1036-url-elicitation

Conversation

@sainathreddyb
Copy link
Copy Markdown

Summary

Add URL-type elicitation schema support allowing servers to request URL input from users during tool execution (SEP-1036).

Changes:

  • UrlElicitationSchema and UrlElicitationResult types in McpSchema.java
  • Client-side URL elicitation handler registration and dispatch in McpAsyncClient, McpClient, and McpClientFeatures
  • Server exchange methods for URL elicitation requests in McpAsyncServerExchange and McpSyncServerExchange
  • Comprehensive tests for schema serialization, client handler dispatch, and server exchange round-trips

Motivation and Context

SEP-1036 introduces a URL elicitation type, enabling MCP servers to request a URL from the user during tool execution — for example, asking the user to provide a callback URL, a webhook endpoint, or a resource link. This complements the existing form-based elicitation with a purpose-built schema for URL input.

How Has This Been Tested?

  • McpSchemaTests: Serialization/deserialization round-trip tests for UrlElicitationSchema and UrlElicitationResult
  • McpAsyncClientResponseHandlerTests: Client-side handler registration and dispatch for URL elicitation requests
  • McpAsyncServerExchangeTests / McpSyncServerExchangeTests: Server exchange URL elicitation request/response flow
  • Full build passes: ./mvnw clean test — all modules green (BUILD SUCCESS)
  • Tested by creating server that supports url elicitation

Breaking Changes

None. This is a purely additive change — new types and methods alongside existing elicitation support.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the [MCP Documentation](https://modelcontextprotocol.io)
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

This implements the Java SDK side of SEP-1036. The schema types follow the same pattern as the existing ElicitationSchema/ElicitationResult for form-based elicitation, keeping the API consistent.

@sainathreddyb sainathreddyb force-pushed the feature/sep-1036-url-elicitation branch from c48b84e to 166c578 Compare April 27, 2026 23:06
sainathreddyb pushed a commit to sainathreddyb/java-sdk that referenced this pull request May 5, 2026
Add URL-type elicitation schema support allowing servers to request URL
input from users during tool execution. This enables out-of-band
interactions like OAuth flows, payment processing, and API key entry.

Schema changes (following CONTRIBUTING.md rules):
- ElicitRequest: append mode, url, elicitationId at end of record
  components (new optional fields default to null)
- ElicitationCompleteNotification: new record implementing Notification
- ErrorCodes.URL_ELICITATION_REQUIRED (-32042): new error code
- METHOD_NOTIFICATION_ELICITATION_COMPLETE: new method constant

Server exchange:
- createElicitation validates URL mode against client capability
- sendElicitationComplete sends completion notification to client

Client:
- elicitationCompleteConsumer() builder method on SyncSpec and AsyncSpec
- Notification handler dispatches to registered consumers
- Existing elicitation handler naturally receives URL mode requests

Validation:
- Canonical constructor enforces url/elicitationId non-null for URL mode
- Builder rejects requestedSchema when mode is 'url'

Backward compatible: existing form-mode callers are unaffected. Old
constructors delegate to canonical constructor with null for new fields.

Ref modelcontextprotocol#939
@sainathreddyb sainathreddyb force-pushed the feature/sep-1036-url-elicitation branch from d31f97c to 869d1b3 Compare May 5, 2026 21:22
Add URL-type elicitation schema support allowing servers to request URL
input from users during tool execution. This enables out-of-band
interactions like OAuth flows, payment processing, and API key entry.

Schema changes (following CONTRIBUTING.md rules):
- ElicitRequest: append mode, url, elicitationId at end of record
  components (new optional fields default to null)
- ElicitRequest.fromJson: handles missing url/elicitationId in URL mode
  by substituting safe defaults (Case B Rule 2)
- ElicitationCompleteNotification: new record with @JsonCreator fromJson
  factory for lenient wire deserialization
- ErrorCodes.URL_ELICITATION_REQUIRED (-32042): new error code
- METHOD_NOTIFICATION_ELICITATION_COMPLETE: new method constant

Server exchange:
- createElicitation validates URL mode against client capability
- sendElicitationComplete sends completion notification to client
- JSON Schema validation for requestedSchema when validator present

Client:
- elicitationCompleteConsumer() builder method on SyncSpec and AsyncSpec
- Notification handler dispatches to registered consumers

Tests:
- Full Case A tests for optional fields (deser without / omit null / unknown)
- Full Case B tests for required fields (null throws / deser yields default)
- URL mode round-trip, backward compatibility, builder validation
- URL mode deserialization with missing fields

Ref modelcontextprotocol#939
@sainathreddyb sainathreddyb force-pushed the feature/sep-1036-url-elicitation branch from 869d1b3 to c995002 Compare May 11, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant